<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
#parse("/linkandscript.html")
<title>论坛控</title>
</head>
<body>
<table border="0" id="forumlist">
  <tr>
  	<td></td>
    <td>forumid</td>
    <td>siteid</td>
    <td>sitename</td>
    <td>domain</td>
    <td>trp</td>
    <td>titlep</td>
    <td>urlkeyword</td>
    <td>contentp</td>
    
    <td>forumcode</td>
    <td>forumname</td>
    <td>urlp</td>
  </tr>
#set($i = 0)        
#foreach($forumitem in $allforum.getForumsInThisGroup()) 
#set($i = $i+1)
  <tr id="$forumitem.">
	<td>$i</td>
    <td class="forumid">$forumitem.getJson().getString("id")</td>
    <td class="siteid">$forumitem.getJson().getJSONObject("site").getString("id")</td>
    <td class="sitename">$forumitem.getJson().getJSONObject("site").getString("name")</td>
    <td class="domain">
    	<input id='domain$forumitem.getJson().getString("id")' type="text" value='$forumitem.getJson().getJSONObject("site").getString("domain")' oldvalue='$forumitem.getJson().getJSONObject("site").getString("domain")' style="width:150px" forum='$forumitem.getJson().getString("id")' key='domain' target='site'/></td>

    <td class="trp">$forumitem.getJson().getJSONObject("site").getString("trp")</td>
    <td class="titlep">$forumitem.getJson().getJSONObject("site").getString("titlep")</td>
    <td class="urlkeyword">$forumitem.getJson().getJSONObject("site").getString("urlkeyword")</td>
    <td class="contentp">$forumitem.getJson().getJSONObject("site").getString("contentp")</td>

    <td class="forumcode">$forumitem.getJson().getString("code")</td>
    <td class="forumname">$forumitem.getJson().getString("name")</td>
    <td class="urlp">$forumitem.getJson().getJSONObject("site").getString("urlp")</td>
  </tr>
#end<!--end of group-->


  <tr id="forumcode">
  	<td></td>
    <td class="forumid"></td>
    <td class="siteid"></td>
    <td class="sitename"></td>
    <td class="domain"></td>
    <td class="trp"></td>
    <td class="titlep"></td>
    <td class="urlkeyword"></td>
    <td class="contentp"></td>
    
    <td class="forumcode"></td>
    <td class="forumname"></td> 
    <td class="urlp"></td>
  </tr>
</table>


</body>



<script language="javascript">
$(function(){
	sendmsg = false;
	
	$(".addforumbtn").live('click', function(){
			$.post('/hezi/forumlist?action=createforum',{
				forumjson: $(this).attr("forumjson")
				},function(theback)
			  	{
				console.log("back:" + theback);
				}
			);
		 });		
	});
	
	
	$("#forumlist input").blur(function(){
		forum = $(this).attr("forum");
		key = $(this).attr("key");
		target = $(this).attr("target");
		newvalue = $(this).val();
		oldvalue = $(this).attr("oldvalue");
		
		if(oldvalue != newvalue){
			$(this).attr("oldvalue",newvalue);
			console.log(forum + ":" + key + ":" +  oldvalue + "->" + newvalue);
			
			$.post('/hezi/forumlist?action=update',{forum: forum, 
								key: key,
								target: target,
								newvalue:newvalue,
								},function(theback)
			  {
				console.log("back:" + theback);
				}
			);
			
		}
		
	});
	
	
	
	  var myDataRef = new Firebase('https://luntankong.firebaseIO.com/');
	  	  
	  var forum = new Firebase('https://luntankong.firebaseIO.com/forums/xqq20');
	  forum.on('value', function(snapshot) {
        var obj = snapshot.val();
		console.log("论坛:");
		console.log(obj);
		
		console.log(obj.site.id)
		
		$("#forumcode .siteid").html(obj.site.id)
		$("#forumcode .sitename").html(obj.site.name)
		$("#forumcode .domain").html(obj.site.domain)
		$("#forumcode .urlp").html(obj.site.urlp)
		$("#forumcode .trp").html(obj.site.trp)
		$("#forumcode .titlep").html(obj.site.titlep)
		$("#forumcode .urlkeyword").html(obj.site.urlkeyword)
		$("#forumcode .contentp").html(obj.site.contentp)
		$("#forumcode .forumid").html(obj.id)
		$("#forumcode .forumcode").html(obj.code)
		$("#forumcode .forumname").html(obj.name)
		
		var forumjson = JSON.stringify(obj)
		var tdstr = "<td><a forum='" + obj.site.id + "' forumjson='" + forumjson + "' class='btn btn-info addforumbtn'>添加</a></td>";
		$("#forumcode").append($(tdstr));  
	  	
})
</script>



<style>
td{
	border:#000 1px solid; 
	padding:4px;
	white-space:nowrap;
}
</style>
</html>
